package com.cloud.freeflow.api.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cloud.freeflow.api.entity.ProcTransDef;
import com.cloud.freeflow.api.mapper.ProcTransDefMapper;
import com.cloud.freeflow.api.service.ProcTransDefService;

@Service
@Transactional
public class ProcTransDefServiceImpl implements ProcTransDefService {

	@Autowired
	private ProcTransDefMapper procTransDefMapper;

	@Override
	public ProcTransDef createProcTrans(ProcTransDef trans) {
		procTransDefMapper.insertSelective(trans);
		return trans;
	}

	@Override
	public List<ProcTransDef> listProcTrans(ProcTransDef trans) {
		return procTransDefMapper.searchProcTransByProcId(trans.getProcDefId());
	}

	@Override
	public long delete(long id) {
		ProcTransDef trans = new ProcTransDef();
		trans.setDeleteFlag(1);
		trans.setTransId(id);
		procTransDefMapper.updateByPrimaryKeySelective(trans);
		return id;
	}

	@Override
	public ProcTransDef load(Long id) {
		return procTransDefMapper.load(id);
	}

	@Override
	public ProcTransDef updateTrans(ProcTransDef trans) {
		ProcTransDef transDef = procTransDefMapper.selectByPrimaryKey(trans);
		transDef.setTransName(trans.getTransName());
		transDef.setFilterSql(trans.getFilterSql());
		procTransDefMapper.updateByPrimaryKey(transDef);
		return transDef;
	}

}
